<?php

namespace App\Http\Controllers\home\product;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\type;
use App\Models\product;
use DB;

class ProductController extends Controller
{
    //
    public function index()
    {
    }
    //获取前台所有商品分类
    public function typelist()
    {
        $type=new Type();
        $typelist=$type->typeGet();
        return view('home.product.typelist',['typelist'=>$typelist]);
//        return 111;
    }
    public function type($tmp)
    {
        $product=new Product();
        //假设标签按照逗号拼接查询 模糊查询
        $list=$product->where('label','like','%'.$tmp.'%')->get();
        return view('home.product.product',['list'=>$list]);

    }


    //搜索框的模糊查询 按照名字查询
    public function seacrhpro(Request $request)
    {
//        dd($request);
        $sousuo=$request->input('sousuo');
        $product=new Product();
        $list=$product->where('name','like','%'.$sousuo.'%')->get();
        return view('home.product.searchlist', ['pro' => $list, 'ziduan' => $sousuo]);


    }
}
